//
//  BaseTableViewController.swift
//  SinaWeibo
//
//  Created by yhlun on 15/11/8.
//  Copyright © 2015年 yhlun. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate {
    
    //添加用户是否登录的标记
    var userLogin = AccountViewModel().userLogin
    
    var visiterLoginView : VisitorLoginView?
    override func loadView() {
        userLogin ? super.loadView() : loadVisitorView()
        
    }
    
    private func loadVisitorView() {
    
        visiterLoginView = VisitorLoginView()
        //设置代理
        visiterLoginView?.visitorDelegate = self
        view = visiterLoginView
        
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "visitorWillLogin")
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "visitorWillRegister")
     
    }
    
    //MARK: 实现协议方法
    
    func visitorWillLogin() {
        print("come in")
        
        let oath = OauthViewController()
        let nav = UINavigationController(rootViewController: oath)
        presentViewController(nav, animated: true, completion: nil)
    }
    
    func visitorWillRegister() {
        print("come on")
    }
    
    
    
 
    override func viewDidLoad() {
        super.viewDidLoad()
    }

}
